package com.monkey.luffer.design.pattern.factory;

/**
 * @Author dengkaibing
 * @Description 运算工厂类
 * @Date 2022/4/4 14:52
 **/
public class OperationFactory {
    /**
     * 根据运算符生成运算类
     * @param operate
     * @return
     */
    public static Operation createOperation(String operate) {
        Operation operation = null;
        // 工厂模式只是解决创建对象问题 当出现多个对象时，必须通过修改工厂类来解决 存在一定的问题
        switch (operate) {
            case "+":
                operation = new OperationAdd(1,3);
                break;
//            case "-":
//                operation = new OperationSub();
//                break;
//            case "*":
//                operation = new OperationMul();
//                break;
//            case "/":
//                operation = new OperationDiv();
//                break;
            default:
                break;
        }
        return operation;
    }
}
